﻿using System; 
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tools.Domain.Specifications;
using Tools.Domain.Specifications.SpecificationSet;
using Tools.Domain.Validation;
using Webshop20.Domain.Customers.Core;
using Webshop20.Domain.Model.Customers;
using Rhino.Mocks;
using Web.App.Infrastructure.ApplicationMessages.Contracts;
using Tools.Domain.Specifications.Constraints;
using Webshop20.Domain.Shared.Payment.Core;

namespace Webshop20.UnitTests.Builder
{
    public class BuildCustomer
    {

        public int? _id = 1;
        public string _firstName = "Hans";
        public string _lastName = "Mustermann";
        public string _eMail = "mustermann@dddddx.de";
        public DateTime registrationDate = DateTime.Now;
        public IPayment payment = new DirectDebit();
        public Adress adress = new Adress("Musterstrasse", "Musterstadt", "66666", "Musterland");

        public IPayment _payment;
        public List<IFailure> _ruleFailures = new List<IFailure>();

        public IConstraintSet<Customer> _constraint = new BuildConstraintSet<Customer>().Build();
        
        public BuildCustomer()
        {
            
        }

        public BuildCustomer WithId(int? id)
        {
            _id = id;
            return this;
        }

        public BuildCustomer WithFirstName(string firstName)
        {
            _firstName = firstName;
            return this;
        }

        public BuildCustomer WithLastName(string lastName)
        {
            _lastName = lastName;
            return this;
        }

        public BuildCustomer WithEMail(string eMail)
        {
            _eMail = eMail;
            return this;
        }

        public BuildCustomer WithAdrees(Adress adress)
        {
            this.adress = adress;
            return this;
        }





        private Customer Build()
        {
            //throw new NotImplementedException();
            return new Customer(_firstName, _lastName, _eMail,payment, registrationDate, adress) { Id = (int)_id};
        }

        public static implicit operator Customer(BuildCustomer builder) 
        {
            return builder.Build();    
        }


        public BuildCustomer WithPaymentMethod(IPayment payment)
        {
            this.payment = payment;
            return this;
        }
    }
}